package io.github.tangwan.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * @author tangwan
 * @version V1.0
 * created on 2021/5/28 10:34
 * @since JDK 1.8
 */
@Getter
@AllArgsConstructor
public enum OrderStatusEnum {

    /**
     * 待支付
     */
    WAIT_PAY(1,"待支付"),
    /**
     * 已支付
     */
    PAID(2,"已支付"),
    /**
     * 待发货
     */
    WAIT_DELIVER(3,"待发货"),
    /**
     * 已发货
     */
    DELIVERED(4,"已发货");

    private Integer code;
    private String desc;

    public static final Map<Integer,OrderStatusEnum> CONTAINER = new HashMap<>();

    static {
        for (OrderStatusEnum orderStatusEnum : OrderStatusEnum.values()){
            CONTAINER.put(orderStatusEnum.getCode(),orderStatusEnum);
        }
    }

    public OrderStatusEnum getByCode(Integer code){
        if (code == null){
            return null;
        }
        return CONTAINER.get(code);
    }

}
